﻿using System;
using System.IO;
using System.Security.Cryptography;

namespace Ares.Engine
{
    public static class BackupHelper
    {
        /// <summary>
        /// Creates an MD5 Hash for the supplied file
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static String MD5HashFromFile(String source)
        {
            //Read file
            FileStream FileCheck = File.OpenRead(source);
            //Get MD5-Hash from Byte-Array
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] md5Hash = md5.ComputeHash(FileCheck);
            FileCheck.Close();

            //Convert to string
            string Berechnet = BitConverter.ToString(md5Hash).Replace("-", "").ToLower();
            return Berechnet;
        }
    }
}
